/*-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License.You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
	
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
	
The Original Code is Fever RS ( ActionScript 3 ) Framework code.
	
The Initial Developer of the Original Code is Romain Ecarnot.
Portions created by Initial Developer are Copyright (C) 2006
the Initial Developer. All Rights Reserved.
	
Contributor(s):
	
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-----------------------------------------------------------------------------*/

package fever.events 
{
	import flash.events.Event;
	
	import com.bourre.events.BasicEvent;	

	/**
	 * The AnalyticEvent class represents the event object passed to the event 
	 * listener for <strong>Analytic tracking</strong> events.
	 * 
	 * @see fever.plugin.analytic.AnalyticPlugin
	 * 
	 * @author Romain Ecarnot
	 */
	final public class AnalyticEvent extends BasicEvent
	{
		//--------------------------------------------------------------------
		// Events
		//--------------------------------------------------------------------
		
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onTrackLink</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>linkURL</code></td>
	     *     	<td>Tracked link</td>
	     *     </tr>     
	     *     <tr>
	     *     	<td><code>linkType</code></td>
	     *     	<td>Link type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onTrackLink
		 */
		public static const onTrackLinkEVENT : String = "onTrackLink";
		
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onTrackLinkDone</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>linkURL</code></td>
	     *     	<td>Tracked link</td>
	     *     </tr>     
	     *     <tr>
	     *     	<td><code>linkType</code></td>
	     *     	<td>Link type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onTrackLinkDone
		 */
		public static const onTrackLinkDoneEVENT : String = "onTrackLinkDone";
		
		
		//--------------------------------------------------------------------
		// Private properties
		//--------------------------------------------------------------------
		
		private var _sLinkURL : String;		private var _sLinkType : String;
		
		
		//--------------------------------------------------------------------
		// Public properties
		//--------------------------------------------------------------------
		
		/** Tracked link. */
		public function get linkURL() : String { return _sLinkURL; }
		/** @private */
		public function set linkURL( s : String ) : void { _sLinkURL = s; }
		
		/**
		 * Link type.
		 * 
		 * <p>Can be :
		 * <ul>
		 *   <li>AnalyticLinkType.OUTGOING_LINK</li>
		 *   <li>AnalyticLinkType.DOWNLOAD_LINK</li>
		 *   <li>Or <code>null</code> ( default ) for classic link</li>
		 * </ul></p>
		 * 
		 * @see fever.plugin.analytic.AnalyticLinkType#OUTGOING_LINK		 * @see fever.plugin.analytic.AnalyticLinkType#DOWNLOAD_LINK
		 */
		public function get linkType() : String { return _sLinkType; }
		/** @private */
		public function set linkType( s : String ) : void { _sLinkType = s; }
		
		
		//--------------------------------------------------------------------
		// Public API
		//--------------------------------------------------------------------
		
		/**
		 * Constructor.
		 * 
		 * @param pType Event type
		 * @param link Tracked link
		 * @param trackType Link type ( default <code>null</code> )
		 */
		public function AnalyticEvent( pType : String, link : String, trackType : String = null )
		{
			super( pType );
			
			_sLinkURL = link;
			_sLinkType = trackType;
		}
		
		/**
		 * Returns <code>AnalyticEvent</code> clone instance.
		 */
		override public function clone() : Event
		{
			return new 	AnalyticEvent( _sType, _sLinkURL, _sLinkType );
		}
	}
}
